<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="noodp" />
    <title class="pjax-title">pacman包管理常用命令 - 我的笔记</title><meta name="Description" content="记录常用的笔记"><meta property="og:title" content="pacman包管理常用命令" />
<meta property="og:description" content="-S 指令安装 sudo pacman -S #安装软件 sudo pacman -Sy #获取最新打软件情况，如果已经是最新了，直接会提示已经更新到最新了。 sudo pacman -Syy #强行更新你的应用的软件库（源） sudo" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://g0ngjie.gitee.io/pacman/" /><meta property="og:image" content="https://g0ngjie.gitee.io/images/avatar.jpg"/><meta property="article:section" content="posts" />
<meta property="article:published_time" content="2022-02-23T00:00:00+00:00" />
<meta property="article:modified_time" content="2022-02-24T13:22:47+08:00" /><meta property="og:site_name" content="我的笔记" />

<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image" content="https://g0ngjie.gitee.io/images/avatar.jpg"/>

<meta name="twitter:title" content="pacman包管理常用命令"/>
<meta name="twitter:description" content="-S 指令安装 sudo pacman -S #安装软件 sudo pacman -Sy #获取最新打软件情况，如果已经是最新了，直接会提示已经更新到最新了。 sudo pacman -Syy #强行更新你的应用的软件库（源） sudo"/>
<meta name="application-name" content="我的笔记">
<meta name="apple-mobile-web-app-title" content="我的笔记">

<meta name="theme-color" content="#f8f8f8"><meta name="msapplication-TileColor" content="#da532c"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
        <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
        <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"><link rel="manifest" href="/site.webmanifest"><link rel="canonical" href="https://g0ngjie.gitee.io/pacman/" /><link rel="next" href="https://g0ngjie.gitee.io/docker%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" /><link rel="stylesheet" href="/lib/normalize/normalize.min.css"><link rel="stylesheet" href="/css/style.min.css"><link rel="preload" as="style" onload="this.onload=null;this.rel='stylesheet'" href="/lib/fontawesome-free/all.min.css">
        <noscript><link rel="stylesheet" href="/lib/fontawesome-free/all.min.css"></noscript><link rel="preload" as="style" onload="this.onload=null;this.rel='stylesheet'" href="/lib/animate/animate.min.css">
        <noscript><link rel="stylesheet" href="/lib/animate/animate.min.css"></noscript>
    
    
    
    <meta name="google-site-verification" content="MQ8DNu27ayX6B_4ObiEDK09vGr1fdy7kOAnbd09hJk4" /><script type="application/ld+json">
    {
        "@context": "http://schema.org",
        "@type": "BlogPosting",
        "headline": "pacman包管理常用命令",
        "inLanguage": "zh-CN",
        "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": "https:\/\/g0ngjie.gitee.io\/pacman\/"
        },"image": ["https:\/\/g0ngjie.gitee.io\/images\/Apple-Devices-Preview.png"],"genre": "posts","keywords": "arch","wordcount":  446 ,
        "url": "https:\/\/g0ngjie.gitee.io\/pacman\/","datePublished": "2022-02-23T00:00:00+00:00","dateModified": "2022-02-24T13:22:47+08:00","license": "This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.","publisher": {
            "@type": "Organization",
            "name": "xxxx","logo": "https:\/\/g0ngjie.gitee.io\/images\/avatar.jpg"},"author": {
                "@type": "Person",
                "name": "Gj"
            },"description": ""
    }
    </script></head>

<body header-desktop="fixed" header-mobile="auto"><script type="text/javascript">
        function setTheme(theme) {document.body.setAttribute('theme', theme);}
        function saveTheme(theme) {window.localStorage && localStorage.setItem('theme', theme);}
        function getMeta(metaName) {const metas = document.getElementsByTagName('meta'); for (let i = 0; i < metas.length; i++) if (metas[i].getAttribute('name') === metaName) return metas[i]; return '';}
        if (window.localStorage && localStorage.getItem('theme')) {let theme = localStorage.getItem('theme');theme === 'light' || theme === 'dark' || theme === 'black' ? setTheme(theme) : (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? setTheme('dark') : setTheme('light')); } else { if ('dark' === 'light' || 'dark' === 'dark' || 'dark' === 'black') setTheme('dark'), saveTheme('dark'); else saveTheme('auto'), window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? setTheme('dark') : setTheme('light');}
        let metaColors = {'light': '#f8f8f8','dark': '#252627','black': '#000000'}
        getMeta('theme-color').content = metaColors[document.body.getAttribute('theme')];
    </script>
    <div id="back-to-top"></div>
    <div id="mask"></div><div class="wrapper"><header class="desktop" id="header-desktop">
    <div class="header-wrapper">
        <div class="header-title">
            <a href="/" title="我的笔记">笔记</a>
        </div>
        <div class="menu">
            <div class="menu-inner"><a class="menu-item" href="/posts/"> 所有文章 </a><a class="menu-item" href="/tags/"> 标签 </a><a class="menu-item" href="/categories/"> 分类 </a><a class="menu-item" href="http://www.alrale.cn/" rel="noopener noreffer" target="_blank"> 作品 </a><a class="menu-item" href="https://github.com/g0ngjie" title="GitHub" rel="noopener noreffer" target="_blank"><i class='fab fa-github fa-fw'></i>  </a><span class="menu-item delimiter"></span><span class="menu-item search" id="search-desktop">
                        <input type="text" placeholder="搜索文章标题或内容..." id="search-input-desktop">
                        <a href="#" onclick="return false;" class="search-button search-toggle" id="search-toggle-desktop" title="搜索">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="#" onclick="return false;" class="search-button search-clear" id="search-clear-desktop" title="清空">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-desktop">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </span><a href="#" onclick="return false;" class="menu-item theme-switch" title="切换主题">
                    <i class="fas fa-adjust fa-fw"></i>
                </a></div>
        </div>
    </div>
</header><header class="mobile" id="header-mobile">
    <div class="header-container">
        <div class="header-wrapper">
            <div class="header-title">
                <a href="/" title="我的笔记">笔记</a>
            </div>
            <div class="menu-toggle" id="menu-toggle-mobile">
                <span></span><span></span><span></span>
            </div>
        </div>
        <div class="menu" id="menu-mobile"><div class="search-wrapper">
                    <div class="search mobile" id="search-mobile">
                        <input type="text" placeholder="搜索文章标题或内容..." id="search-input-mobile">
                        <a href="#" onclick="return false;" class="search-button search-toggle" id="search-toggle-mobile" title="搜索">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="#" onclick="return false;" class="search-button search-clear" id="search-clear-mobile" title="清空">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-mobile">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </div>
                    <a href="#" onclick="return false;" class="search-cancel" id="search-cancel-mobile">
                        取消
                    </a>
                </div><a class="menu-item" href="/posts/" title="">所有文章</a><a class="menu-item" href="/tags/" title="">标签</a><a class="menu-item" href="/categories/" title="">分类</a><a class="menu-item" href="http://www.alrale.cn/" title="" rel="noopener noreffer" target="_blank">作品</a><a class="menu-item" href="https://github.com/g0ngjie" title="GitHub" rel="noopener noreffer" target="_blank"><i class='fab fa-github fa-fw'></i></a><a href="#" onclick="return false;" class="menu-item theme-switch" title="切换主题">
                <i class="fas fa-adjust fa-fw"></i>
            </a></div>
    </div>
</header>
<div class="search-dropdown desktop">
    <div id="search-dropdown-desktop"></div>
</div>
<div class="search-dropdown mobile">
    <div id="search-dropdown-mobile"></div>
</div>
<main class="main">
            <div class="container"><div class="toc" id="toc-auto">
        <h2 class="toc-title">目录</h2>
        <div class="toc-content" id="toc-content-auto"><nav id="TableOfContents">
  <ul>
    <li>
      <ul>
        <li><a href="#-s-指令">-S 指令</a></li>
        <li><a href="#-r-指令">-R 指令</a></li>
        <li><a href="#-q-指令">-Q 指令</a></li>
        <li><a href="#查询孤儿软件并删除掉他们">查询孤儿软件并删除掉他们</a></li>
      </ul>
    </li>
  </ul>
</nav></div>
    </div><script>document.getElementsByTagName("main")[0].setAttribute("pageStyle", "wide")</script><script>document.getElementsByTagName("main")[0].setAttribute("autoTOC", "true")</script><article class="page single"><h1 class="single-title animate__animated animate__flipInX">pacman包管理常用命令</h1><div class="post-meta">
            <div class="post-meta-line">
                <span class="post-author"><i class="author fas fa-user-circle fa-fw"></i><a href="/" title="Author" rel=" author" class="author">Gj</a>
                </span>&nbsp;<span class="post-category">收录于 </span>&nbsp;<span class="post-category">类别 <a href="/categories/linux/"><i class="far fa-folder fa-fw"></i>linux</a></span></div>
            <div class="post-meta-line"><i class="far fa-calendar-alt fa-fw"></i>&nbsp;<time datetime="2022-02-23">2022-02-23</time>&nbsp;<i class="far fa-edit fa-fw"></i>&nbsp;<time datetime="2022-02-24">2022-02-24</time>&nbsp;<i class="fas fa-pencil-alt fa-fw"></i>&nbsp;约 446 字&nbsp;
                <i class="far fa-clock fa-fw"></i>&nbsp;预计阅读 1 分钟&nbsp;</div>
        </div><div class="details toc" id="toc-static"  kept="">
                <div class="details-summary toc-title">
                    <span>目录</span>
                    <span><i class="details-icon fas fa-angle-right"></i></span>
                </div>
                <div class="details-content toc-content" id="toc-content-static"><nav id="TableOfContents">
  <ul>
    <li>
      <ul>
        <li><a href="#-s-指令">-S 指令</a></li>
        <li><a href="#-r-指令">-R 指令</a></li>
        <li><a href="#-q-指令">-Q 指令</a></li>
        <li><a href="#查询孤儿软件并删除掉他们">查询孤儿软件并删除掉他们</a></li>
      </ul>
    </li>
  </ul>
</nav></div>
            </div><div class="content" id="content"><p><img
        class="lazyload"
        data-src="/images/linux/pacman/bg.png"
        data-srcset="/images/linux/pacman/bg.png, /images/linux/pacman/bg.png 1.5x, /images/linux/pacman/bg.png 2x"
        data-sizes="auto"
        alt="/images/linux/pacman/bg.png"
        title="bg"></p>
<h3 id="-s-指令" class="headerLink">
    <a href="#-s-%e6%8c%87%e4%bb%a4" class="header-mark"></a>-S 指令</h3><p>安装</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell">sudo pacman -S <span class="c1">#安装软件</span>

sudo pacman -Sy <span class="c1">#获取最新打软件情况，如果已经是最新了，直接会提示已经更新到最新了。</span>

sudo pacman -Syy <span class="c1">#强行更新你的应用的软件库（源）</span>

sudo pacman -Su <span class="c1">#更新所有软件</span>

sudo pacman -Syu <span class="c1">#更新软件源并更新你的软件</span>

sudo pacman -Syyu <span class="c1">#强行更新一遍，再更新软件</span>
</code></pre></div><p>查询一个软件</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell">sudo pacman -Ss &lt;pkg_name&gt; <span class="c1">#查询所有软件名里面带有&lt;pkg_name&gt;相关的软件。并且查询名支持正则表达</span>
</code></pre></div><p>删除软件/var 目录下的缓存</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell">sudo pacman -Sc
</code></pre></div><h3 id="-r-指令" class="headerLink">
    <a href="#-r-%e6%8c%87%e4%bb%a4" class="header-mark"></a>-R 指令</h3><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell">sudo pacman -R &lt;pkg_name&gt; <span class="c1">#删除软件</span>

sudo pacman -Rs &lt;pkg_name&gt; <span class="c1">#删除软件，并删除&lt;pkg&gt;所有的依赖包</span>

sudo pacman -Rns &lt;pkg_name&gt; <span class="c1">#删除软件，并删除&lt;pkg&gt;所有的依赖，并删掉&lt;pkg&gt;的全局配置文件。 推荐！！</span>
</code></pre></div><h3 id="-q-指令" class="headerLink">
    <a href="#-q-%e6%8c%87%e4%bb%a4" class="header-mark"></a>-Q 指令</h3><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell">sudo pacman -Q <span class="c1">#显示出所有软件 sudo pacman -Q | wc -l 查询数量</span>

sudo pacman -Qe <span class="c1">#查询所有自己安装的软件</span>

sudo pacman -Qeq <span class="c1">#查询所有自己安装的软件，只显示包名，不显示版本号等</span>

sudo pacman -Qs &lt;pkg_name&gt; <span class="c1">#查询本地安装的所有带&lt;pkg_name&gt;的软件</span>

sudo pacman -Qdt <span class="c1">#查询所有孤儿软件，不再被需要的。</span>

sudo pacman -Qdtq <span class="c1">#查询所有不再被依赖的包名</span>
</code></pre></div><h3 id="查询孤儿软件并删除掉他们" class="headerLink">
    <a href="#%e6%9f%a5%e8%af%a2%e5%ad%a4%e5%84%bf%e8%bd%af%e4%bb%b6%e5%b9%b6%e5%88%a0%e9%99%a4%e6%8e%89%e4%bb%96%e4%bb%ac" class="header-mark"></a>查询孤儿软件并删除掉他们</h3><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell">sudo pacman -R <span class="k">$(</span>sudo pacman -Qdtq<span class="k">)</span>
</code></pre></div></div>

        <div class="post-footer" id="post-footer">
    <div class="post-info">
        <div class="post-info-line">
            <div class="post-info-mod">
                <span>更新于 2022-02-24&nbsp;<a class="git-hash" href="https://gitee.com/g0ngjie/g0ngjie/commit/6828785c50ef2df0468e5891db650ba0352ee3dc" target="_blank" title="commit by Gj(gongjie0422@163.com) 6828785c50ef2df0468e5891db650ba0352ee3dc: deploy" rel="noopener noreferrer">
                                    <i class="fas fa-hashtag fa-fw"></i>6828785</a></span>
            </div>
            <div class="post-info-license"></div>
        </div>
        <div class="post-info-line">
            <div class="post-info-md"></div>
            <div class="post-info-share">
                <span></span>
            </div>
        </div>
    </div>

    <div class="post-info-more">
        <section class="post-tags"><i class="fas fa-tags fa-fw"></i>&nbsp;<a href="/tags/arch/">arch</a></section>
        <section>
            <span><a href="javascript:void(0);" onclick="window.history.back();">返回</a></span>&nbsp;|&nbsp;<span><a href="/">主页</a></span>
        </section>
    </div>

    <div class="post-nav">
            <a href="/docker%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" class="next" rel="next" title="Docker常用命令">Docker常用命令<i class="fas fa-angle-right fa-fw"></i></a></div>
</div>
</article></div>
        </main><footer class="footer">
        <div class="footer-container"><div class="footer-line"></div>
            <div class="footer-line"></div>
            <div class="footer-line">
            </div>
        </div><script>
                    if('serviceWorker' in navigator) {
                        navigator.serviceWorker
                            .register('/sw.min.js', { scope: '/' })
                            .then(function(registration) {
                            });
                
                        navigator.serviceWorker
                            .ready
                            .then(function(registration) {
                            });
                    }
                </script></footer></div>

    <div id="fixed-buttons"><a href="#back-to-top" id="back-to-top-button" class="fixed-button" title="回到顶部">
            <i class="fas fa-arrow-up fa-fw"></i>
        </a><a href="#" id="view-comments" class="fixed-button" title="查看评论">
            <i class="fas fa-comment fa-fw"></i>
        </a>
    </div><div class="assets"><script type="text/javascript" src="/lib/autocomplete/autocomplete.min.js"></script><script type="text/javascript" src="/lib/lunr/lunr.min.js"></script><script type="text/javascript" src="/lib/lunr/lunr.stemmer.support.min.js"></script><script type="text/javascript" src="/lib/lunr/lunr.zh.min.js"></script><script type="text/javascript" src="/lib/lazysizes/lazysizes.min.js"></script><script type="text/javascript" src="/lib/tablesort/tablesort.min.js"></script><script type="text/javascript" src="/lib/topbar/topbar.min.js"></script><script type="text/javascript" src="/lib/pjax/pjax.min.js"></script><script type="text/javascript" src="/js/theme.min.js"></script></div>

<div class="pjax-assets"><script type="text/javascript">window.config={"code":{"copyTitle":"复制到剪贴板","maxShownLines":15},"comment":{},"search":{"highlightTag":"em","lunrIndexURL":"/index.json","lunrLanguageCode":"zh","lunrSegmentitURL":"/lib/lunr/lunr.segmentit.js","maxResultLength":10,"noResultsFound":"没有找到结果","snippetLength":50,"type":"lunr"},"table":{"sort":true}};</script><script type="text/javascript" src="/lib/clipboard/clipboard.min.js"></script></div>
</body>

</html>